#pragma once

#include "atlstr.h"
#include "AddIn.h"
#include "Connect.h"
#include "RunProcess.h"
#include "CpUtil.h"
#include <list>

using namespace std;

class CConnect;
class CTestSuiteTool
{
public:
	CTestSuiteTool(CConnect* pParent);
	virtual ~CTestSuiteTool(void);

public:
	int HandleCommand(int nCmd);
	void CreateProjectFromTemplate();
	void RunSolutionWithCoverage(BOOL bIntsrAll);
	void StopCoverage();
	void BuildDone();
	virtual void OutputLogString(LPCTSTR lpszStr);

protected:
	CString MergePath(LPCWSTR sBasePath, LPCWSTR sRelPath);
	CString ParentDir(const CString& sPath);
	CString GetRelPath(LPCWSTR sBasePath, LPCWSTR sDestPath);
	CString FindFirstName(TCHAR*& sPath);
	TCHAR* RemoveSepFromBegin(TCHAR* sPath);
	void AlignRelPath(BSTR& bstrInput, LPCWSTR sOrig, LPCWSTR sDest);
	void MergeMacroDef(BSTR& bstrMacro);
	//Additional Include Path: nType = 1 
	//Additional Library Path: nType = 2
	//Additional Dependency lib: nType = 3
	void AlignRelPathEx(BSTR& bstrInput, LPCWSTR sOrig, LPCWSTR sDest, int nType);

	BOOL EqualBSTR(BSTR s1, BSTR s2);
	void ClonePrjConfigurations(VCProject* basePrj, VCProject* newPrj);
	void GetConfigure(LPCTSTR szName, IVCCollection* manager, VCConfiguration** cfg);
	void CopyConfig(VCConfiguration* baseCfg, BSTR bstrBasePath, VCConfiguration* newCfg, BSTR bstrNewPath);

	CString GetStartProject(EnvDTE::_Solution* solution, EnvDTE::SolutionBuild* builder);
	void GetStartProjectObj(EnvDTE::_Solution* sln, CString szStartName, EnvDTE::Project** startPrj, VCProject** startVCPrj);
	CString GetProjectOutputPath(EnvDTE::Project* startPrj, VCProject* startVCPrj);
	void InstrumentAssembly(const CString& szToolPath, const CString& sOutPath);
	void RestoreChangedProject();

protected:
	enum CommandEnums
	{
		Command_CreateTestProject,
		Command_RunTestProject,
		Command_AutoMock
	};
	CConnect* m_pParent;
	CProcessLaunch m_Instrument;
	CProcessLaunch m_PerformMon;
	CProcessLaunch m_PerformStop;
	CProcessLaunch m_Run;
	CString m_sOutPath;
	list<VCLinkerTool*> m_changedList;
	list<CString> m_lstFiles;
};
